package com.bvgol.quartzDemo.config;

import com.bvgol.quartzDemo.job.HelloJob2;
import org.quartz.JobBuilder;
import org.quartz.JobDataMap;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.CronTriggerFactoryBean;

import java.util.Date;

/**
 * @program: my-spring-completely
 * @description:
 * @author: GUOCHEN
 * @create: 2023/03/14 09:57
 */
//@Component
public class CornJobConfig {
    @Autowired
    private Scheduler scheduler;

//    @PostConstruct
    protected void InitHelloJob() throws Exception {
        JobDetail jobDetail = JobBuilder.newJob(HelloJob2.class)
                .withIdentity("helloJob2")
//                .storeDurably()
                .usingJobData("data2", "保密信息2")
                .build();
        CronTriggerFactoryBean cronTrigger = new CronTriggerFactoryBean();
        cronTrigger.setName("");
        cronTrigger.setGroup("");
        cronTrigger.setJobDetail(jobDetail);
        cronTrigger.setJobDataMap(new JobDataMap());
//        cronTrigger.setJobDataAsMap(new HashMap<String,?>());
        cronTrigger.setStartTime(new Date());
        cronTrigger.setStartDelay(0L);
        cronTrigger.setCronExpression("");
//        cronTrigger.setTimeZone(new TimeZone());
        cronTrigger.setCalendarName("");
        cronTrigger.setPriority(0);
        cronTrigger.setMisfireInstruction(0);
        cronTrigger.setMisfireInstructionName("");
        cronTrigger.setDescription("");
        cronTrigger.setBeanName("");

//        scheduler.scheduleJob(jobDetail,cronTrigger);
        //推荐这种写法`

    }
}
